package com.zr.util;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;
/**
 * printwriter的工具类
 * @author Administrator
 *
 */
public class PrintWriterUtil {
	/**
	 * 获得，并且设置字符集为utf8
	 * @param resp
	 * @return
	 */
	public static PrintWriter getPW(HttpServletResponse resp){
		resp.setCharacterEncoding("utf8");
		PrintWriter pw = null;
		try {
			pw = resp.getWriter();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return pw;
	}
	/**
	 * 关闭pw
	 * @param resp
	 */
	public static void closePW(HttpServletResponse resp){
		PrintWriter pw = null;
		try {
			pw = resp.getWriter();
			pw.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
